//
//  SAMemberHistoryCell.m
//  saasRetail
//
//  Created by 黄志刚 on 2021/6/28.
//

#import "SAMemberHistoryCell.h"
#import "SAMemberHistoryModel.h"

@interface SAMemberHistoryCell ()

@property (nonatomic, strong) UILabel *titleLab;
@property (nonatomic, strong) UILabel *numLab;
@property (nonatomic, strong) UILabel *dateLab;
@property (nonatomic, strong) UILabel *priceLab;
@property (nonatomic, strong) UIImageView *allowImageV;

@end

@implementation SAMemberHistoryCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self initUI];
    }
    return self;
}

-(void)setModel:(SAMemberHistoryModel *)model {
    _model = model;
    self.titleLab.text = [NSString stringWithFormat:@"%@",model.salesOrderNo];
    self.numLab.text = [NSString stringWithFormat:@"%@",model.totalCount];
    
    double actualPrice = [model.actualPrice doubleValue];
    if (actualPrice < 0) {
        self.priceLab.textColor = kBuleColor;
    }else {
        self.priceLab.textColor = kPinkColor;
    }
    self.priceLab.text = [NSString stringWithFormat:@"%0.2lf",actualPrice/100];
    self.dateLab.text = [NSString stringWithFormat:@"%@  %@",model.storeName,model.createTime];
}

-(void)initUI {
    self.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:self.titleLab];
    [self.contentView addSubview:self.dateLab];
    [self.contentView addSubview:self.priceLab];
    [self.contentView addSubview:self.numLab];
    [self.contentView addSubview:self.allowImageV];
}

-(UILabel *)titleLab {
    if (!_titleLab) {
        _titleLab = [[UILabel alloc] initWithFrame:SARectMake(26, 7, 125, 20)];
        _titleLab.textColor = kBlackColor;
        _titleLab.font = kFont(15);
    }
    return _titleLab;
}

-(UILabel *)numLab {
    if (!_numLab) {
        _numLab = [[UILabel alloc] initWithFrame:SARectMake(151, 7, 73, 20)];
        _numLab.textColor = kBlackColor;
        _numLab.font = kFont(15);
        _numLab.textAlignment = NSTextAlignmentCenter;
    }
    return _numLab;
}

-(UILabel *)dateLab {
    if (!_dateLab) {
        _dateLab = [[UILabel alloc] initWithFrame:SARectMake(26, 27, kBaseScreenWidth - 59, 20)];
        _dateLab.textColor = kBlackColor;
        _dateLab.font = kFont(15);
        _dateLab.textAlignment = NSTextAlignmentRight;
    }
    return _dateLab;
}

-(UILabel *)priceLab {
    if (!_priceLab) {
        _priceLab = [[UILabel alloc] initWithFrame:SARectMake(kBaseScreenWidth - 130, 7, 97, 20)];
        _priceLab.textColor = kBlackColor;
        _priceLab.font = kFont(15);
        _priceLab.textAlignment = NSTextAlignmentRight;
    }
    return _priceLab;
}

-(UIImageView *)allowImageV {
    if (!_allowImageV) {
        _allowImageV = [[UIImageView alloc] initWithFrame:SARectMake(357, 21, 7, 13)];
        _allowImageV.image = [UIImage imageNamed:@"shop_grayAllow"];
    }
    return _allowImageV;
}


@end
